<?php

use Illuminate\Support\Facades\Route;

/*
 * |--------------------------------------------------------------------------
 * | Web Routes
 * |--------------------------------------------------------------------------
 * |
 * | Here is where you can register web routes for your application. These
 * | routes are loaded by the RouteServiceProvider within a group which
 * | contains the "web" middleware group. Now create something great!
 * |
 */

// Auth::routes();
Route::group([
    'namespace' => 'Auth'
], function () {
    Route::get('login', 'LoginController@showLoginForm')->name('login');
    Route::post('login', 'LoginController@login');

    Route::group([
        'middleware' => ['auth', 'auth.user.config']
    ], function () {
        // 退出
        Route::post('logout', 'LoginController@logout')->name('logout');
        // 密码重置路由
        Route::get('pwd/reset', 'ResetPwdController@showResetForm')->name('pwd.request');
        Route::post('pwd/reset', 'ResetPwdController@reset')->name('pwd.update');
        // google2fa
        Route::get('g2fa', 'Google2faController@index')->name('g2fa.request');
        Route::post('g2fa', 'Google2faController@verify')->name('g2fa.verify');
    });
});

Route::get('/', 'AdminController@index')->middleware(['auth', 'auth.user.config', 'auth.reset.pwd', 'auth.g2fa'])->name('admin');

// Exports【统计】
Route::group([
    'prefix' => 'stats',
    'namespace' => 'Stats'
], function () {
    // 游戏分析
    Route::group([
        'prefix' => 'game',
        'namespace' => 'Game'
    ], function () {
        // 游戏统计
        Route::group([
            'prefix' => 'game',
            'middleware' => 'can:menu.stats.game.game'
        ], function () {
            Route::get('export', 'GameController@export');
            Route::get('exportUsd', 'GameController@exportUsd');
        });
    });
    // 平台分析
    Route::group([
        'prefix' => 'platform',
        'namespace' => 'Platform'
    ], function () {
        // 平台统计
        Route::group([
            'prefix' => 'settlement',
            'middleware' => 'can:menu.stats.platform.settlement'
        ], function () {
            Route::get('exportAll', 'SettlementController@exportAll');
            Route::get('exportGame', 'SettlementController@exportGame');
            Route::get('exportGameScene', 'SettlementController@exportGameScene');
            Route::get('exportUsd', 'SettlementController@exportUsd');
        });
    });
    // 玩家分析
    Route::group([
        'prefix' => 'user',
        'namespace' => 'User'
    ], function () {
        // 玩家投注
        Route::group([
            'prefix' => 'player-bet',
            'middleware' => 'can:menu.stats.user.player-bet'
        ], function () {
            Route::get('exportHour', 'PlayerBetController@exportHour');
            Route::get('exportDay', 'PlayerBetController@exportDay');
            Route::get('exportMonth', 'PlayerBetController@exportMonth');
        });
    });
});
// Exports【平台】
Route::group([
    'prefix' => 'platform',
    'namespace' => 'Platform'
], function () {
    // 平台收益
    Route::group([
        'prefix' => 'settlement',
        'middleware' => 'can:menu.platform.settlement'
    ], function () {
        Route::get('exportDay', 'SettlementController@exportDay');
        Route::get('exportMonth', 'SettlementController@exportMonth');
        Route::get('exportUsd', 'SettlementController@exportUsd');
    });
});
// Exports【游戏】
Route::group([
    'prefix' => 'game',
    'namespace' => 'Game'
], function () {
    // 数据
    Route::group([
        'prefix' => 'data',
        'namespace' => 'Data'
    ], function () {
        // 游戏记录
        Route::group([
            'prefix' => 'settlement',
            'middleware' => 'can:menu.game.data.settlement'
        ], function () {
            Route::get('export', 'SettlementController@export');
        });
    });
});
// Exports【支付】
Route::group([
    'prefix' => 'pay',
    'namespace' => 'Pay'
], function () {
    // 订单管理
    Route::group([
        'prefix' => 'order',
        'namespace' => 'Order'
    ], function () {
        // 转入转出
        Route::group([
            'prefix' => 'transfer',
            'middleware' => 'can:menu.pay.order.transfer'
        ], function () {
            Route::get('export', 'TransferController@export');
        });
        // 共享钱包
        Route::group([
            'prefix' => 'wallet',
            'middleware' => 'can:menu.pay.order.wallet'
        ], function () {
            Route::get('export', 'WalletController@export');
        });
    });
});
